package com.zzxx.controller;



import com.github.pagehelper.PageInfo;
import com.zzxx.pojo.Orders;
import com.zzxx.service.OrderService;
import org.apache.ibatis.annotations.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
//@CrossOrigin
@RequestMapping("order")
public class OrderController {
	@Autowired
	private OrderService orderService;

	@RequestMapping(value = "find", method = RequestMethod.GET)
	public PageInfo<Orders> findAll(Integer pageNum, Integer pageSize){
		pageNum = pageNum==null? 1:pageNum;
		pageSize = pageSize==null? 5:pageSize;
		PageInfo<Orders> pageInfo = orderService.findAll(pageNum, pageSize);
		return pageInfo;
	}

	@RequestMapping(value = "find/{id}", method = RequestMethod.GET)
	public Orders findById(@PathVariable("id") String id){
		Orders order = orderService.findById(id);
		return order;
	}

	@RequestMapping(value = "update", method = RequestMethod.PUT)
	public boolean update(@RequestBody Map<String,Orders> map){
		Orders order = map.get("order");
		return orderService.update(order);
	}

	@RequestMapping(value = "test", method = RequestMethod.GET)
	public void test(){
		System.out.println("aaaa");
	}

}
